import { createStore, applyMiddleware } from "redux";
import reduxLogger from "redux-logger";
import { thunk } from "redux-thunk";
import reduxPromise from "redux-promise";

import reducer from "./reducer";

const middleware = [reduxPromise, reduxLogger];
const env = process.env.NODE_ENV;
if (env === "development") {
  middleware.push(thunk);
}

// 根据不同环境，使用不同中间件
const store = createStore(reducer, applyMiddleware(...middleware));

export default store;
